﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

using permit.App_Code.DataAccess;
using permit.App_Code.Entity;

namespace permit.opPermit
{
    public partial class DisplayPermit : System.Web.UI.Page
    {
        DataSet ds;
        PermitAccess perAccess = new PermitAccess();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                ds = perAccess.GetPermits((PermitTable)Session["Permit"]);

                if (ds == null || ds.Tables[0].Rows.Count == 0)
                {
                    Response.Redirect("queryPermit.aspx?Sturt=no");
                }
                else
                {
                    if (Request.QueryString["print"] == "1")
                    {
                        gvNoPrint.DataSource = ds;
                        gvNoPrint.DataBind();
                    }
                    if (Request.QueryString["print"] == "0")
                    {
                        Gridview2.DataSource = ds;
                        Gridview2.DataBind();
                    }
                    
                }
            }
        }
       
        protected void Gridview2_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            Gridview2.PageIndex = e.NewPageIndex;
            ds = perAccess.GetPermits((PermitTable)Session["Permit"]);
            Gridview2.DataSource = ds;
            Gridview2.DataBind();
            
        }

        protected void gvNoPrint_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvNoPrint.PageIndex = e.NewPageIndex;
            ds = perAccess.GetPermits((PermitTable)Session["Permit"]);
            gvNoPrint.DataSource = ds;
            gvNoPrint.DataBind();
        }


    }
}
